package com.beans;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
public class UserBeans {
    @Bean//注：只使用一个bean注解是无法将对象存储到容器中
    public User user1(){
        User user=new User();
        user.setId(1);
        user.setName("张丹");
        return user;

    }

    @Bean(name="user2")
    @Scope("prototype")
    public User getuser2(){
        User user=new User();
        user.setId(1);
        user.setName("java");
        return user;

    }
}
